# install.packages("devtools")
# devtools::install_github("MathiasHarrer/dmetar")

library(dmetar)
library("meta")

# 
# GLPT1DMMETA= read.rm5(
#   "GLP-1 for Type 1 Diabetes- Raw Final.rm5",
#   sep = ",",
#   quote = "\"",
#   "GLP-1 for Type 1 Diabetes- Raw Final",
#   numbers.in.labels = TRUE,
#   debug = 0
# )
# 
# c1o3<- metacr(GLPT1DMMETA,comp.no=1, outcome.no=3)
# funnel(c1o3)
# 
# # Contour-enhanced funnel plot with user-chosen colours
# #
# funnel(c1o1, random = TRUE,
#        level = 0.95,  contour = c(0.9, 0.95, 0.99),
#        col.contour = c("darkgreen", "green", "lightgreen"),  
#        lwd.random = 2, cex=1,
#        studlab = TRUE, pos.studlab=1, cex.studlab = 0.7)
# legend(0.05, 0.05,
#        c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
#        fill = c("darkgreen", "green", "lightgreen"))
#        







GLPT1DMMETA_p= read.rm5(
  "GLP-1 for Type 1 Diabetes- Raw Final.rm5",
  sep = ",",
  quote = "\"",
  "GLP-1 for Type 1 Diabetes- Raw Final",
  numbers.in.labels = TRUE,
  debug = 0
)

c1o1 <- metacr(GLPT1DMMETA_p,comp.no=1, outcome.no=1)
funnel(c1o1, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(0.95, 0.05,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c1o1)

c1o2 <- metacr(GLPT1DMMETA_p,comp.no=1, outcome.no=2)
funnel(c1o2, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(-1.5, 0.05,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c1o2)


c1o3 <- metacr(GLPT1DMMETA_p,comp.no=1, outcome.no=3)
funnel(c1o3, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(7, 0.05,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c1o3)



c1o4 <- metacr(GLPT1DMMETA_p,comp.no=1, outcome.no=4)
funnel(c1o4, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(0.1, 0.005,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c1o4)



c2o1 <- metacr(GLPT1DMMETA_p,comp.no=2, outcome.no=1)
funnel(c2o1, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(0.95, 0.05,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c2o1)

c2o2 <- metacr(GLPT1DMMETA_p,comp.no=2, outcome.no=2)
funnel(c2o2, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(-1.5, 0.05,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c2o2)


c2o3 <- metacr(GLPT1DMMETA_p,comp.no=2, outcome.no=3)
funnel(c2o3, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(7, 0.05,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c2o3)



c2o4 <- metacr(GLPT1DMMETA_p,comp.no=2, outcome.no=4)
funnel(c2o4, random = TRUE,
       level = 0.95,  contour = c(0.9, 0.95, 0.99),
       col.contour = c("darkgreen", "green", "lightgreen"),
       lwd.random = 2, cex=1,
       studlab = TRUE, pos.studlab=2, cex.studlab = 0.7)
legend(0.1, 0.005,
       c("0.1 > p > 0.05", "0.05 > p > 0.01", "< 0.01"),
       fill = c("darkgreen", "green", "lightgreen"))
eggers.test(c2o4)


